1. Field
The embodiments discussed herein are directed to a graphics drawing apparatus, a graphics drawing method, and a graphics drawing program which draw graphics by using a memory corresponding to a two-dimensional coordinate system consisting of an X-axis representing a direction in which consecutive memory addresses are arranged and a Y-axis representing the direction intersecting the X-axis in applications such as computer graphics, and to a recording medium on which the program is recorded.
2. Description of the Related Art
Stencil buffers, which store the shapes of graphics to be drawn, are used in applications such as computer graphics. There are the following techniques for drawing a desired graphic in a stencil buffer area. For example, there is a technique in which, for a sequence of vertex coordinates input from a vertex coordinate stream, triangles that share vertex coordinates input as the coordinates of the leading vertex are drawn by using exclusive-OR operation one by one each time vertex coordinates are input, thereby forming a final graphic to be drawn (hereinafter referred to as a “subject graphic”).
In another technique, each time vertex coordinates are input from a vertex coordinate stream, sides of the contour of a subject graphic, each being formed by the coordinates of two adjacent vertices, are drawn one by one and a rectangle is drawn from each of the sides drawn to one! end of a stencil buffer area by using exclusive-OR operation, thereby constructing a subject graphic (for example, see Japanese Patent Laid-Open No. 2001-209812 and No. 10-188010).
However, the existing technique described earlier has a problem that, because all the triangles that make up subject graphic share the coordinates of the leading vertex as described above, the coordinates of the other vertices of some triangles are positioned far away from the leading vertex coordinates and therefore many scan lines are involved in the drawing.
When many scan lines are involved, the difference between memory addresses associated with the pixels on the scan lines is large and therefore data cannot efficiently be transferred from a VRAM (Video RAM) to a stencil buffer with burst access and the rendering speed decreases. Furthermore, when many triangles in which many scan lines are involved are drawn, the scan lines are swept back and forth many times to draw the triangles. Random access to the VRAM takes place at each sweep, which reduces the rendering speed.
The technique disclosed in Japanese Patent Laid-Open No. 2001-209812 or No. 10-188010 draws pixels in the direction in which consecutive memory addresses are arranged and therefore can alleviate the problem described above. However, scan lines involved in drawing are processed to their ends. Thus, the technique suffers from low rendering speeds because rendering is applied to a wider range than necessary. Additionally, the technique requires implementation of an extra dedicated mechanism called a scan line algorithm, adding to the cost of the products (a detailed description of which is omitted here since it is well known in the art).